package com.zhangxiaofanfan.hotcode.third;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * TODO
 *
 * @author zhangxiaofanfan
 * @date 2024-05-29 21:50:21
 */
public class HotCode036 {
    public static void main(String[] args) {

    }

    public List<Integer> inorderTraversal(TreeNode root) {
        List<Integer> list = new ArrayList<>();
        if (root == null) {
            return list;
        }
        bfs(root, list);
        return list;
    }

    public void bfs(TreeNode node, List<Integer> list) {
        if (node == null) {
            return ;
        }
        bfs(node.left, list);
        list.add(node.val);
        bfs(node.right, list);
    }

    static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode() {
        }

        TreeNode(int val) {
            this.val = val;
        }

        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }
}
